﻿using System;

namespace FortuneCookie.EPiServer.SearchAndReplace.Data
{
    /// <summary>
    /// Data helper factory class
    /// </summary>
    internal sealed class DataHelperFactory
    {

        /// <summary>
        /// Creates a new data helper
        /// </summary>
        /// <returns>IDataHelper</returns>
        public static IDataHelper CreateDataHelper()
        {
            Type type = Type.GetType(Configuration.ConfigurationHelper.DataHelperFullTypeName);

            if (type == null)
                throw new Exception("The DataHelper configured for SearchAndReplace does not exist.");

            return (IDataHelper)Activator.CreateInstance(type);
        }

    }
}
